package com.aloda.controller.user;

import com.aloda.constant.ErrorCode;
import com.aloda.result.Result;
import com.aloda.service.AnalysisService;
import com.aloda.vo.analysis.AnalysisAppResultVO;
import com.aloda.vo.analysis.AnalysisAppUserAnswerVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("ana-user")
@RequestMapping("/user/analysis")
public class AnalysisController {

    @Resource
    private AnalysisService analysisService;

    /**
     * 获取app用户答题次数分析
     * @return
     */
    @GetMapping("/answer/{id}")
    public Result<AnalysisAppUserAnswerVO> analysisAppAnswerUser(@PathVariable Long id) {
        if (id == null) {
            return Result.error(ErrorCode.PARAMS_ERROR);
        }
        return Result.success(analysisService.analysisAppAnswerUser(id));
    }

    /**
     * 获取app答题结果分析
     * @param id
     * @return
     */
    @GetMapping("/result/{id}")
    public Result<AnalysisAppResultVO> analysisAppResult(@PathVariable Long id) {
        if (id == null) {
            return Result.error(ErrorCode.PARAMS_ERROR);
        }
        return Result.success(analysisService.analysisAppResult(id));
    }
}
